package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import com.atguigu.yygh.vo.order.SignInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @FileName: ScheduleController
 * @Author Steven
 * @Date: 2021/3/24
 */
@Api(tags = "排班管理")
@RestController
@RequestMapping("admin/hosp/schedule")
public class ScheduleController {

    @Autowired
    ScheduleService scheduleService;

    @ApiOperation("分页查询排版信息")
    @GetMapping("/{current}/{limit}/{hosCode}/{deptCode}")
    public Result scheduleRule(@PathVariable Integer current,
                              @PathVariable Integer limit,
                              @PathVariable String hosCode,
                              @PathVariable String deptCode){
        Map<String, Object> scheduleRule = scheduleService.getScheduleRule(current, limit, hosCode, deptCode);
        return Result.ok(scheduleRule);
    }

    @ApiOperation("根据医院编号、部门编号、排版日期查询排版信息")
    @GetMapping("{hosCode}/{deptCode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hosCode,
                                    @PathVariable String deptCode,
                                    @PathVariable String workDate){
        List<Schedule> schedules = scheduleService.getDetailSchedule(hosCode, deptCode, workDate);
        return Result.ok(schedules);
    }

    @ApiOperation(value = "根据排班id获取预约下单数据")
    @GetMapping("inner/getScheduleOrderVo/{scheduleId}")
    public Result getScheduleOrderVo(
            @ApiParam(name = "scheduleId", value = "排班id", required = true)
            @PathVariable("scheduleId") String scheduleId) {
        return Result.ok(scheduleService.getScheduleOrderVo(scheduleId));
    }

    @ApiOperation(value = "获取医院签名信息")
    @GetMapping("inner/getSignInfoVo/{hoscode}")
    public Result getSignInfoVo(
            @ApiParam(name = "hoscode", value = "医院code", required = true)
            @PathVariable("hoscode") String hoscode) {
        return Result.ok(scheduleService.getSignInfoVo(hoscode));
    }

}
